package com.ruoyi.web.controller.test1;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.test.domain.Warehousemanagement;
import com.ruoyi.test.service.IWarehousemanagementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓库管理Controller
 * 
 * @author 22082109czy
 * @date 2025-07-07
 */
@RestController
@RequestMapping("/warehouse/warehousemanagement")
public class WarehousemanagementController extends BaseController
{
    @Autowired
    private IWarehousemanagementService warehousemanagementService;

    /**
     * 查询仓库管理列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:warehousemanagement:list')")
    @GetMapping("/list")
    public TableDataInfo list(Warehousemanagement warehousemanagement)
    {
        startPage();
        List<Warehousemanagement> list = warehousemanagementService.selectWarehousemanagementList(warehousemanagement);
        return getDataTable(list);
    }



    /**
     * 查询所有仓库列表（用于下拉框）
     */
    @GetMapping("/listAll")
    public AjaxResult listAll() {
        List<Warehousemanagement> list = warehousemanagementService.selectWarehousemanagementList(new Warehousemanagement());
        return success(list);
    }
    /**
     * 导出仓库管理列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:warehousemanagement:export')")
    @Log(title = "仓库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Warehousemanagement warehousemanagement)
    {
        List<Warehousemanagement> list = warehousemanagementService.selectWarehousemanagementList(warehousemanagement);
        ExcelUtil<Warehousemanagement> util = new ExcelUtil<Warehousemanagement>(Warehousemanagement.class);
        util.exportExcel(response, list, "仓库管理数据");
    }

    /**
     * 获取仓库管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('warehouse:warehousemanagement:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(warehousemanagementService.selectWarehousemanagementById(id));
    }

    /**
     * 新增仓库管理
     */
    @PreAuthorize("@ss.hasPermi('warehouse:warehousemanagement:add')")
    @Log(title = "仓库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Warehousemanagement warehousemanagement)
    {
        return toAjax(warehousemanagementService.insertWarehousemanagement(warehousemanagement));
    }

    /**
     * 修改仓库管理
     */
    @PreAuthorize("@ss.hasPermi('warehouse:warehousemanagement:edit')")
    @Log(title = "仓库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Warehousemanagement warehousemanagement)
    {
        return toAjax(warehousemanagementService.updateWarehousemanagement(warehousemanagement));
    }

    /**
     * 删除仓库管理
     */
    @PreAuthorize("@ss.hasPermi('warehouse:warehousemanagement:remove')")
    @Log(title = "仓库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(warehousemanagementService.deleteWarehousemanagementByIds(ids));
    }
}
